package com.kanasco.engg.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.mvc.SimpleFormController;







import bb.common.PartVO;

import com.kanasco.engg.model.Item;
import com.kanasco.engg.services.IItemService;

public class EnggListController implements Controller {
	public IItemService itemService;
	EnggListController(){
	}

/* (non-Javadoc)
 * @see org.springframework.web.servlet.mvc.Controller#handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
public ModelAndView handleRequest(HttpServletRequest request,
		HttpServletResponse response)throws IOException,ServletException{
	System.out.println("this si EngglIst Cotroller");
	//PartVO itemType=new PartVO();
	HttpSession session=request.getSession();
	Item itemType=new Item();
	ModelAndView mv=new ModelAndView("AddItem","item", itemType);
	
	
	List<String> itemTypes =itemService.getAllItemTypes();
	 mv.addObject("itemTypeList",itemTypes);
	
	List<String> itemUnits=itemService.getAllItemUOMs();
	mv.addObject("itemUnitList",itemUnits);
	System.out.println("itemUnitList"+itemUnits);
	session.setAttribute("itemUnitList",itemUnits);
	
	List<String> ShippingWtUnitList=itemService.getAllItemShippingWtUnits();
	mv.addObject("ShippingWtUnitList",ShippingWtUnitList);
	System.out.println("shippingwtUnit"+ShippingWtUnitList);
	session.setAttribute("ShippingWtUnitList",ShippingWtUnitList);
	
	List<String> buyerCodeList=itemService.getAllBuyerCode();
	mv.addObject("buyerCodeList",buyerCodeList);
	System.out.println("buyerCode is"+buyerCodeList);
	session.setAttribute("buyerCodeList",buyerCodeList);
	
	List countryList=new ArrayList();
	countryList.add("");
	countryList.add("Made in India");
	countryList.add("Made in US");
	countryList.add("Made in UK");
	mv.addObject("countryList", countryList);
	session.setAttribute("countryList",countryList);
	List makeList=new ArrayList();
	makeList.add("Make");
	makeList.add("Buy");
	mv.addObject("makeList", makeList);
	session.setAttribute("makeList",makeList);
	
	List inspectionTypeList=new ArrayList();
	inspectionTypeList.add("Compulsory inspection");
	inspectionTypeList.add("Exemption from inspection");
	inspectionTypeList.add("Sampling inspection");
	mv.addObject("inspectionTypeList",inspectionTypeList);
	session.setAttribute("inspectionTypeList",inspectionTypeList);
	
	List volumeUnit =new ArrayList();
	volumeUnit.add("");
	volumeUnit.add("cu.m");
	volumeUnit.add("cu.in");
	volumeUnit.add("cu.ft.");
	mv.addObject("volumeUnit",volumeUnit);
	session.setAttribute("volumeUnit",volumeUnit);
	return mv;
}

public void setItemService(IItemService itemService) {
	this.itemService = itemService;
}

}
